1. /* sdfsinSR.cpp by K.Tsuru */
  2. // function ID 3105 DRADIX
  3. /***************
  4. SDouble class
  5. sin x
  6. using sereies and reduction method.
  7. Old version's Sin(x) before ver 2.2.
  8. ****************/
  9. #ifndef SN_H
  10. #include "sn.h"
  11. #endif
  12. #define usesSinSeriesInSin 1 // for a test.
  13. SDouble SinS_RN(const SDouble& x){
  14. if(x.Sign() == 0) return x; // x = 0
  15. #if usesSinSeriesInSin
  16. // |x| is very small.
  17. if(x.NetRdxExp() < -4) return SinSeries(x); // |x| < 1.0e-16 ver.2.18
  18. uint fig = x.Last() - x.First() +1u;
  19. double c;
  20. if(fig <= 5u){ // x has the figures les than five.
  21. double dblX = doubleD(x, 0), absX = fabs(dblX);
  22. // x is short and small, then call SinSeries()
  23. c = (absX > M_PI_4) ? 1.0 : log10((double)x.MaxSize()*absX) - 1.6;
  24. if(c < 0) return SinSeries(x);
  25. }
  26. #endif
  27. SDouble y, r;
  28. int func = SIN_CALC;
  29. int sgn = GetTriCalcMethod(x, y, &func);// |y| < pi/4
  30. if(sgn == 0){ // y = -1, 0, 1
  31. x.upToTerm = 0;
  32. return y;
  33. }
  34. #if usesSinSeriesInSin
  35. // x is long but small.
  36. double dblY = doubleD(y), absY = fabs(dblY);
  37. c = (double)x.MaxSize()/64 + log10(absY) + 0.2;
  38. if(c < 0){
  39. if(func == COS_CALC) r = CosSeries(y);
  40. else r = SinSeries(y);
  41. goto Ret;
  42. }
  43. #endif
  44. //RN : using x/R^n reduction method
  45. if(func == COS_CALC) r = CosRN(y);
  46. else r = SinRN(y);
  47. Ret:
  48. if(sgn < 0) r.ChangeSign(); // r = -r;
  49. return r;
  50. }

sdfsinSR.cpp : last modifiled at 2017/05/08 15:03:00(1,382 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).